FIG. 1 illustrates a conventional IP network data packet 100 comprising an IP header 102 including source and destination IP addresses 104, 106; a UDP header 108 including a length 111, a UDP checksum 110; and a UDP payload 112. Each of these data items comprises a series of digital information units, such as 16-bit words.
A conventional method of UDP checksum calculation will now be described. At the beginning, a 32-bit register is initialized with the protocol type, such as 0x11 for UDP. Then, the source IP address field 104 and destination IP address field 106 of the IP header 102 are added to the 32-bit register. Next some data from the UDP header data 108 is added omitting the checksum datum 110 but doubling the length datum (not illustrated in FIG. 1). Then each datum of the UDP payload 112 is added.
After parsing the data packet 100, the most significant 16 bits and the least significant 16 bits of the 32-bit register are added together and the 2's complement of the result (e.g. subtracting one from the result then applying bit inversion) is calculated to arrive at the UDP checksum value. Finally, this value is written into the UDP checksum 110 of the UDP header 108, for example at the 4th word.
An example of tabulating this checksum calculation is in Table 1 below. The calculation on that input data is a 16-bit word based addition in a 32-bit register:
TABLE 1Item Name16-bit Input32-bit RegisterMAC headerffff00000011ffff00000011ffff00000011002400000011e89d00000011453c00000011080000000011IPv4 header450000000011004400000011bd50000000110000000000118011000000113bd500000011IP Source address0a4b00000a5c373900004195IP Destination addressffff00014194ffff00024193UDP header040500024598079b00024d33length003000024d93Checksum557600024d93Payload4e5600029be935500002d13954440003257d4158000366d541410003a816424e0003ea64535500043db9784d0004b606564400050c4a46430005528d4d3100059fbe5a4f0005fa0d537a00064d874541000692c862330006f4fb4a5400073f4f61580007a0a752420007f2e962578554055410008aa81
In table 1, the 32-bit register begins initialized with the value 0x11, which is the UDP protocol type value. A data processing window reads the data packet 100 one data unit at a time. In table 1 each data unit is 1 word expressed in hexadecimal notation. As the window proceeds word by word through the packet, the relevant data values are accumulated into the 32-bit register value. When the window reaches the length datum, it is added twice to account for the 16-bit size of each datum in the packet. When the window reaches the end of the UDP payload 112, the 32-bit register totals 0x0008AA81. The checksum is then calculated by adding the most significant word (0x0008) and the least significant word (0xAA81) of the 32-bit register and taking the 2's complement of that sum (0x5576). This value is the conventional checksum of the packet and is written into the checksum 110.
Because the processing window proceeds in a unit by unit sequence from the start of the data packet 100 to its end, if the value to be written to a unit is not know at the time it is in the processing window, transmission of any subsequent units must be delayed and any processing of subsequent units while waiting must be stored into a temporary memory buffer.
In a conventional checksum calculation, the checksum final value cannot be determined until the processing window has reached the end of the UDP payload 112. Accordingly temporary memory storage is required to buffer all data units between the UDP checksum 110 and the end of the UDP payload 112 for each data packet 110. The size of this temporary storage depends directly on the size of the UDP payload 112. Because the checksum value cannot be known until all UDP payload data has been processed, transmission of the packet 100 must be delayed from when the processing window reaches the UDP checksum 110 until the processing window reaches the end of the UDP payload 112.
When processing data packets 100 using the conventional method for calculating UDP checksum, a temporary storage (memory) or buffer may hold the entire data packet for the UDP checksum calculation increasing the gate count (memory) of the ASIC.
When real-time processing of data packets is required, the data processing should minimize or eliminate any delay that would prevent sequentially forwarding the packet unit-by-unit after processing unit-by-unit through the data processing window. As described above, this is not possible with conventional checksum calculations. Thus the delivery, transmission or forwarding of any subsequent units in the packet must be delayed until all of the UDP payload 112 has been processed. Providing a data-processing window that can read all of the UDP payload units in parallel requires ever increasing hardware resources and power consumption as the length of UDP payloads increase.